package org.particlethink.model;

import org.particlethink.entry.BillStatus;
import org.particlethink.handler.BillStatusHandler;
import tk.mybatis.mapper.annotation.ColumnType;
import tk.mybatis.mapper.annotation.KeySql;

import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;

@Table(name = "bills")
public class Bill {//对账单 对发货单对账
    @Id
    @KeySql(useGeneratedKeys = true)
    private Integer id;
    private String no;//对账单号
    private Integer projectId;//项目id
    private Integer supplierId;//供货商id
    private Date startAt;//开始时间
    private Date endAt;//结束时间

    @ColumnType(typeHandler = BillStatusHandler.class)
    private BillStatus status;
    private String supplierRemark;//供货商备注
    private String projectRemark;//项目备注

    private Integer creatorId;//创建者id 项目人员
    private Date createdAt;
    private String objectionReason;//异议原因

    private Float deductionAmount; //扣款金额
    private String deductionReason;// 扣款事由
    private Float rewardAmount; //  奖励金额
    private String rewardReason;//  奖励事由

    public Bill(
            Integer projectId,
            String no,
            Float deductionAmount,
            String deductionReason,
            Float rewardAmount,
            String rewardReason,
            Date startAt,
            Date endAt,
            Integer supplierId,
            Integer creatorId,
            Date createdAt
    ) {
        this.projectId = projectId;
        this.deductionAmount = deductionAmount;
        this.no = no;
        this.deductionReason = deductionReason;
        this.startAt = startAt;
        this.rewardAmount = rewardAmount;
        this.endAt = endAt;
        this.rewardReason = rewardReason;
        this.supplierId = supplierId;
        this.status = BillStatus.UnConfirmed;
        this.creatorId = creatorId;
        this.createdAt = createdAt;
    }

    public Bill() {
    }


    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getProjectId() {
        return projectId;
    }

    public void setProjectId(Integer projectId) {
        this.projectId = projectId;
    }

    public Integer getSupplierId() {
        return supplierId;
    }

    public void setSupplierId(Integer supplierId) {
        this.supplierId = supplierId;
    }

    public Date getStartAt() {
        return startAt;
    }

    public void setStartAt(Date startAt) {
        this.startAt = startAt;
    }

    public Date getEndAt() {
        return endAt;
    }

    public void setEndAt(Date endAt) {
        this.endAt = endAt;
    }

    public BillStatus getStatus() {
        return status;
    }

    public void setStatus(BillStatus status) {
        this.status = status;
    }

    public String getSupplierRemark() {
        return supplierRemark;
    }

    public void setSupplierRemark(String supplierRemark) {
        this.supplierRemark = supplierRemark;
    }


    public Integer getCreatorId() {
        return creatorId;
    }

    public void setCreatorId(Integer creatorId) {
        this.creatorId = creatorId;
    }


    public boolean canDiscard() {
        return status == BillStatus.UnConfirmed || status == BillStatus.Objection;
    }

    public boolean canObjection() {
        return status == BillStatus.UnConfirmed;
    }

    public boolean canConfirmed() {
        return status == BillStatus.UnConfirmed;
    }

    public boolean canRecall() {
        return status == BillStatus.Objection;
    }

    public boolean canReCreate() {
        return status == BillStatus.Objection;
    }



    public String getDeductionReason() {
        return deductionReason;
    }

    public void setDeductionReason(String deductionReason) {
        this.deductionReason = deductionReason;
    }




    public String getRewardReason() {
        return rewardReason;
    }

    public void setRewardReason(String rewardReason) {
        this.rewardReason = rewardReason;
    }

    public String getNo() {
        return no;
    }

    public void setNo(String no) {
        this.no = no;
    }

    public void setProjectRemark(String projectRemark) {
        this.projectRemark = projectRemark;
    }

    public String getObjectionReason() {
        return objectionReason;
    }

    public void setObjectionReason(String objectionReason) {
        this.objectionReason = objectionReason;
    }

    public String getProjectRemark() {
        return projectRemark;
    }

    public Date getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(Date createdAt) {
        this.createdAt = createdAt;
    }

    public Float getDeductionAmount() {
        return deductionAmount;
    }

    public void setDeductionAmount(Float deductionAmount) {
        this.deductionAmount = deductionAmount;
    }

    public Float getRewardAmount() {
        return rewardAmount;
    }

    public void setRewardAmount(Float rewardAmount) {
        this.rewardAmount = rewardAmount;
    }
}
